﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data.Common;
using System.Data.EntityClient;

namespace PrvDataModel
{
    public static class ConfigUtils
    {
        public static string GetEFConnection(string connName)
        {
            var originalConnectionString = ConfigurationManager.ConnectionStrings[connName].ConnectionString;
            var entityBuilder = new EntityConnectionStringBuilder(originalConnectionString);
            var factory = DbProviderFactories.GetFactory(entityBuilder.Provider);
            var providerBuilder = factory.CreateConnectionStringBuilder();

            providerBuilder.ConnectionString = entityBuilder.ProviderConnectionString;
//            providerBuilder.Add("Password", "Pquinter97");
            entityBuilder.ProviderConnectionString = providerBuilder.ToString();

            return entityBuilder.ToString();

        }

    }
}
